package com.txf.coomon.net.net_retrofit;

import com.txf.coomon.net.net_retrofit.api.AppApiService;
import com.txf.net_retrofitlibrary.HttpClient;
import com.txf.net_retrofitlibrary.HttpRetrofit;

import okhttp3.Headers;
import okhttp3.OkHttpClient;

/**
 * @author txf
 * @create 2019/1/31 0031
 * @(app请求提供者)
 */
public class AppRequestProvide {
    private final static String ROOT_URL = "http://shopapi.stage.kankanai.com.cn/v1/";
    private static AppApiService mAppApiService;

    public static AppApiService getHttpApiService() {
        if (mAppApiService == null) {
            synchronized (AppRequestProvide.class) {
                if (mAppApiService == null) {
                    new AppRequestProvide();
                }
            }
        }
        return mAppApiService;
    }

    private AppRequestProvide() {
        HttpRetrofit retrofit = new HttpRetrofit();
        Headers headers = new Headers
                .Builder()
                .add("Authorization", "Bearer " + "eyJhbGciOiJIUzUxMiIsImlhdCI6MTU0ODkyMzQ5MiwiZXhwIjozMDk3ODU0MTg0LjY4NDg5MTd9.eyJpYXQiOjE1NDg5MjM0OTIuNjg0ODkxNywidWlkIjoiNWM0NDVmNzUwMWNhNDMwYmVlYjQ0OWYzIiwidXNlcm5hbWUiOiJ0b21hdG8iLCJ0eXBlIjowLCJyIjpmYWxzZX0.U4xpdQ1fXwmDLSgiXl_GxGmdPaHZid6iynMoTY6XNlsuznSYzftFTdtnUITaQKDBvA7dXp3IGTXDGLgFnYQSKA")
                .build();
        OkHttpClient client = HttpClient.getInstance().addHeaders(headers);
        mAppApiService = retrofit.getRetrofit(ROOT_URL, client).create(AppApiService.class);
    }
}
